<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script crossorigin src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
    <script crossorigin src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
    <!-- 生产环境中不建议使用 -->
    <script crossorigin src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>

<body>
    <div id="app"></div>

</body>
<script type="text/babel">
    class Show extends React.Component{
        constructor(){
            super()          
            this.state={
                msg:''
            }  
        }

        componentWillMount(){
            this.thisShow()
        }

        componentDidUpdate(){
            this.thisShow()
        }

        thisShow(){
            if (Number(this.props.v) < Number(this.props.min)) {
                this.setState({
                    msg:'水结冰了'
                })
            }else if(Number(this.props.v) > Number(this.props.max)){
                this.setState({
                    msg:'水烧开了'
                })
            }else{
                this.setState({
                    msg:'烧开了'
                })
            }
        }

        render(){
            return (<div>{this.state.msg}</div>)
        }
    }

    class Water extends React.Component{
        constructor(){
            super()
            this.state={
                WD: -51,
            }
        }

        changed(e){
            this.setState({
                WD:e.target.value
            })
        }

        render(){
            return (<div>
                        <input type="number" onChange={this.changed.bind(this)} defaultValue={this.state.WD}/>
                        <Show v={this.state.WD} min={this.props.min} max={this.props.max}/>
                    </div>)
        }
    }


    ReactDOM.render(<Water min='0' max='80'/>,app)
    
</script>

</html>